<template>
  <div class="app-container">


    <el-col :span="12" class="card-box">
      <el-card>
        <div slot="header"><span>订单录入</span></div>
        <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 750px">
          <!-- 添加或修改NonmetalOrder对话框 -->
          <el-form ref="form" :model="form" :rules="rules" label-width="86px">
            <el-form-item label="订单ID" prop="orderId">
              <el-input v-model="form.orderId" placeholder="请输入订单ID" :disabled="true"  />
            </el-form-item>
            <el-form-item label="客户姓名" prop="clientName">
              <el-input v-model="form.clientName" placeholder="请输入客户姓名" />
            </el-form-item>
            <el-form-item label="客户电话" prop="clientPhone">
              <el-input v-model="form.clientPhone" placeholder="请输入客户电话" />
            </el-form-item>
            <el-form-item label="交付日期" prop="dateReleased">
              <el-date-picker clearable size="small" v-model="form.dateReleased" type="date" value-format="yyyy-MM-dd"
                placeholder="选择交付日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="录入时间" prop="inputime">
              <el-date-picker clearable size="small" v-model="form.inputime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择录入时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="技术交底人" prop="dataPreprocessor">
              <el-select v-model="form.dataPreprocessor" placeholder="请选择技术交底人" clearable size="small">
                <el-option v-for="dict in dict.type.sys_cme_technicalhandover" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="录入人员" prop="salesman">
              <el-select v-model="form.salesman" placeholder="请选择录入人员" clearable size="small">
                <el-option v-for="dict in dict.type.sys_cme_ordermen" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="技术要求" prop="technicalRequirements">
              <el-input type="textarea" v-model="form.technicalRequirements" placeholder="请输入内容" />
            </el-form-item>
            <!--              <el-form-item label="相关文件">-->
            <!--                <fileUpload v-model="form.documents"/>-->
            <!--              </el-form-item>-->
            <el-form-item label="上传">
              <!--<file-upload/>-->
              <file-upload :orderid="form.orderId" />
            </el-form-item>
            <el-form-item label="下载">
              <el-link :underline="false">
                <el-button type="primary" @click="getorderfile">获取文件<i class="el-icon-download el-icon--right"></i>
                </el-button>
              </el-link>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </el-card>
    </el-col>

    <!-- 添加或修改前处理对话框 -->
    <el-col :span="12" class="card-box">
      <el-card>
        <div slot="header"><span>前处理</span></div>
        <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 750px">
          <el-form ref="form" :model="preprocess" :rules="rules" label-width="86px">
            <el-form-item label="订单ID" prop="orderId">
              <el-input v-model="preprocess.orderId" placeholder="请输入订单ID" :disabled="true"  />
            </el-form-item>

            <el-form-item label="前处理人员" prop="dataPreprocessor">

              <el-select v-model="preprocess.dataPreprocessor" placeholder="请输入前处理人员">
                <el-option v-for="dict in dict.type.nonmetal_preprocess_prep" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>

            <el-form-item label="3D打印人员" prop="printer">

              <el-select v-model="preprocess.printer" placeholder="请输入3D打印人员" clearable size="small">
                <el-option v-for="dict in dict.type.nonmetal_3Dprinter" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="处理结果">
              <el-radio-group v-model="preprocess.result">
                <el-radio v-for="dict in dict.type.sys_result" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="是否处理">
              <el-radio-group v-model="preprocess.isHandle">
                <el-radio v-for="dict in dict.type.sys_is_handling" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="处理记录" prop="prePorcessingRecord">
              <el-input v-model="preprocess.prePorcessingRecord" type="textarea" placeholder="请输入处理记录" />
            </el-form-item>
            <el-form-item label="其他" prop="other">
              <el-input v-model="preprocess.other" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="上传">
              <!--<file-upload/>-->
              <preprocess-upload :orderid="preprocess.orderId" />
            </el-form-item>
            <el-form-item label="下载">
              <el-link :underline="false">
                <el-button type="primary" @click="getpreprocessfile">获取文件<i class="el-icon-download el-icon--right"></i>
                </el-button>
              </el-link>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitpreprocess">提交</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </el-card>
    </el-col>

    <!-- 添加或修改打印处理对话框 -->
    <el-col :span="12" class="card-box">
      <el-card>
        <div slot="header"><span>打印处理</span></div>
        <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 780px">
          <el-form ref="form" :model="printprocessList" :rules="rules" label-width="80px">
            <el-form-item label="订单ID" prop="orderId">
              <el-input v-model="printprocessList.orderId" placeholder="请输入订单ID" :disabled="true" />
            </el-form-item>
            <el-form-item label="打印人员" prop="printer">
              <el-select v-model="printprocessList.printer" placeholder="请输入打印人员">
                <el-option v-for="dict in dict.type.nonmetal_printer" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="打印名称" prop="printName">
              <el-input v-model="printprocessList.printName" placeholder="请输入打印名称" />
            </el-form-item>
            <el-form-item label="打印类型" prop="printType">
              <el-select v-model="printprocessList.printType">
                <el-option v-for="dict in dict.type.nonmetal_printtype" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="设备状态">
              <el-radio-group v-model="printprocessList.deviceStatus">
                <el-radio v-for="dict in dict.type.sys_device_status" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="开始时间" prop="startTime">
              <el-date-picker clearable size="small" v-model="printprocessList.startTime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择开始时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间" prop="endTime">
              <el-date-picker clearable size="small" v-model="printprocessList.endTime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择结束时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="打印时长" prop="printTime">
              <el-input v-model="printprocessList.printTime" placeholder="请输入打印时长" />
            </el-form-item>
            <el-form-item label="质检记录" prop="qualityRecord">
              <el-input v-model="printprocessList.qualityRecord" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="是否合格">
              <el-radio-group v-model="printprocessList.isqualitified">
                <el-radio v-for="dict in dict.type.sys_quality_result" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <!--              <el-form-item label="热处理人员" prop="heatPreprocessor">-->
            <!--                <el-input v-model="printprocessList.heatPreprocessor" placeholder="请输入热处理人员" />-->
            <!--              </el-form-item>-->
            <!--              <el-form-item label="是否处理">-->
            <!--                <el-radio-group v-model="printprocessList.isHandle">-->
            <!--                  <el-radio-->
            <!--                    v-for="dict in dict.type.sys_is_handling"-->
            <!--                    :key="dict.value"-->
            <!--                    :label="parseInt(dict.value)"-->
            <!--                  >{{dict.label}}</el-radio>-->
            <!--                </el-radio-group>-->
            <!--              </el-form-item>-->
            <el-form-item label="异常记录" prop="unnormalRecord">
              <el-input v-model="printprocessList.unnormalRecord" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitprintprocess">提交</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </el-card>
    </el-col>

    <!-- 添加或修改后处理对话框 -->
    <el-col :span="12" class="card-box">
      <el-card>
        <div slot="header"><span>后处理</span></div>
        <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 780px">
          <el-form ref="form" :model="postprocessList" :rules="rules" label-width="80px">
            <el-form-item label="订单ID" prop="orderId">
              <el-input v-model="postprocessList.orderId" placeholder="请输入订单ID" :disabled="true"  />
            </el-form-item>
            <el-form-item label="后处理人" prop="postProcessor">
              <el-select v-model="postprocessList.postProcessor" placeholder="请输入后处理人">
                <el-option v-for="dict in dict.type.nonmetal_postman" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="设备状态">
              <el-radio-group v-model="postprocessList.deviceStatus">
                <el-radio v-for="dict in dict.type.sys_device_status" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="开始时间" prop="startTime">
              <el-date-picker clearable size="small" v-model="postprocessList.startTime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择开始时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间" prop="overTime">
              <el-date-picker clearable size="small" v-model="postprocessList.overTime" type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择结束时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="处理时长" prop="postProcessTime">
              <el-input v-model="postprocessList.postProcessTime" placeholder="请输入处理时长" />
            </el-form-item>
            <el-form-item label="操作记录" prop="qualityRecord">
              <el-input v-model="postprocessList.qualityRecord" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="是否合格">
              <el-radio-group v-model="postprocessList.isqualified">
                <el-radio v-for="dict in dict.type.sys_quality_result" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="是否处理">
              <el-radio-group v-model="postprocessList.isHandl">
                <el-radio v-for="dict in dict.type.sys_is_handling" :key="dict.value" :label="parseInt(dict.value)">
                  {{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="异常记录" prop="unusualRecord">
              <el-input v-model="postprocessList.unusualRecord" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="其他" prop="other">
              <el-input v-model="postprocessList.other" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitPostprocess">提交</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </el-card>
    </el-col>

  </div>
</template>

<script>
  import {
    listPreprocess,
    getPreprocess,
    delPreprocess,
    addPreprocess,
    updatePreprocess
  } from "@/api/cmenonmetalapi/preprocess";
  import {
    listNonmetalOrder,
    getNonmetalOrder,
    delNonmetalOrder,
    addNonmetalOrder,
    updateNonmetalOrder
  } from "@/api/Nonmetal/NonmetalOrder";
  import {
    listPostprocess,
    getPostprocess,
    delPostprocess,
    addPostprocess,
    updatePostprocess
  } from "@/api/cmenonmetalapi/postprocess";
  import {
    listProcess,
    getProcess,
    delProcess,
    addProcess,
    updateProcess
  } from "@/api/cmenonmetalapi/printprocess";
  import {
    download
  } from '@/utils/request';
  import FileUpload from "@/views/cmenonmetal/file/FileUpload";
  import PreprocessUpload from "@/views/cmenonmetal/file/PreprocessUpload";
  import ElFormItem from "element-ui/packages/form/src/form-item";
  import {
    listZxorderurl
  } from "@/api/cmecomon/zxorderurl";
  import {
    getFileInformation,
    listZsorderurl
  } from '@/api/cmenonmetalapi/zsorderurl';


  export default {
    name: "cmenonmetaldetail",
    dicts: ['sys_result', 'sys_is_handling', 'sys_device_status', 'sys_quality_result', 'nonmetal_3Dprinter',
      'nonmetal_preprocess_prep', 'sys_cme_ordermen', 'nonmetal_printer', 'nonmetal_printtype', 'nonmetal_postman',
      'sys_cme_technicalhandover'
    ],
    components: {
      ElFormItem,
      FileUpload,
      PreprocessUpload,
    },
    data() {
      return {
        // 遮罩层
        loading: true,

        // 表单参数
        form: {},
        preprocess: {},
        urlList: {},
        printprocessList: {},
        heatPreprocessList: {},
        wirecutList: {},
        postprocessList: {},
        //order文件名
        orderfilename: null,
        //order文件路径
        orderurl: null,

        //前处理文件名
        predatafilename: null,
        //前处理文件路径
        predataurl: null,
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderId: null,
          oederid: null,
          resource: "http://localhost:8080/profile/upload/2022/01/17/ac411ff8-3d86-44c4-9093-241560962f56.zip",
        },
        // whatfile: 111110
      };
    },
    created() {
      this.getList();
    },
    mounted() {

    },
    methods: {

      getList() {
        this.loading = true;
        //获取路由跳转时的传参
        let orderid = this.$route.query.orderid
        this.queryParams.orderId = orderid;
        this.queryParams.oederid = orderid;
        //获取订单原始数据
        listNonmetalOrder(this.addDateRange(this.queryParams)).then(response => {
          this.form = response.rows[0];
        });

        //获取url原始数据
        listZsorderurl(this.queryParams).then(response => {
          this.urlList = response.rows[0];
        });

        //获取前处理数据原始数据
        listPreprocess(this.queryParams).then(response => {
          this.preprocess = response.rows[0];
        });
        //获取文件信息
        getFileInformation(this.queryParams).then(response => {
          this.orderfilename = response.orderfilename;
          this.orderurl = response.orderurl;
          this.predatafilename = response.predatafilename;
          this.predataurl = response.predataurl;
        });
        //获取打印数据
        listProcess(this.queryParams).then(response => {
          this.printprocessList = response.rows[0];
        });

        //获取后处理数据
        listPostprocess(this.queryParams).then(response => {
          this.postprocessList = response.rows[0];
        });
        this.loading = false;
      },


      //order文件下载
      getorderfile() {
        this.queryParams.resource = this.urlList.orderUpload;
        download("/cmenonmetal/download/resource", this.queryParams, "非金属原始文件：" + this.queryParams.orderId + this
          .orderfilename);
      },

      //datapreprocess文件下载
      getpreprocessfile() {
        this.queryParams.resource = this.urlList.perprocessUpload;
        download("/cmenonmetal/download/resource", this.queryParams, "非金属前处理文件" + this.queryParams.orderId + this
          .predatafilename);
      },
      /** 提交修改order按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            updateNonmetalOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改订单信息成功");
              this.open = false;
              this.getList();
            });
          }
        });
      },

      //**提交修改preprocess按钮*/
      submitpreprocess() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            updatePreprocess(this.preprocess).then(response => {
              this.$modal.msgSuccess("修改前处理信息成功");
              this.open = false;
              this.getList();
            });
          }
        });
      },

      //**提交修改printprocess按钮*/
      submitprintprocess() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            updateProcess(this.printprocessList).then(response => {
              this.$modal.msgSuccess("修改打印过程数据成功");
              this.open = false;
              this.getList();
            });
          }
        });
      },

      /** 提交修改Postprocess按钮 */
      submitPostprocess() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            updatePostprocess(this.postprocessList).then(response => {
              this.$modal.msgSuccess("修改后处理数据成功");
              this.open = false;
              this.getList();
            });
          }
        });
      },


    }
  }

</script>

<style scoped>
  .dialog-footer {
    float: right
  }

</style>
